<!--
 * @Author: your name
 * @Date: 2021-07-26 14:28:04
 * @LastEditTime: 2021-11-24 10:23:59
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \jinfeng_up\src\views\login.vue
-->
<template>
  <div>
    <div class="content">
      <div class="content_input">
        <div class="title">
          <p>金风反馈平台</p>
        </div>
        <el-input v-model="UserName" clearable placeholder="用户名"></el-input>
        <el-input
          v-model="PassWord"
          clearable
          show-password
          placeholder="密码"
        ></el-input>
        <div class="content_button">
          <el-button type="primary" size="middle" @click="LoGin"
            >登录</el-button
          >
        </div>
      </div>
    </div>
  </div>
</template>
<script>
// import { Login } from '@/api/setting/service.js'
import axios from 'axios'
import Qs from 'qs'
import Base64 from '@/utils/code.js'
export default {
    data() {
        return {
            UserName: '',
            PassWord: ''
        }
    },
    methods: {
        LoGin() {
            const param = {
                loginname: this.UserName,
                pwd: Base64.encode(this.PassWord)
            }
            axios({
                url: 'https://devops.goldwind.com.cn/beta/v2/auth/user/login',
                method: 'POST',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                },
                data: Qs.stringify(param)
            }).then((res) => {
                console.log('res=>', res)
                if (res.data.errcode == '0') {
                    sessionStorage.setItem('USERINFO', JSON.stringify(res.data.data))
                    this.$router.push('/myWait')
                } else {
                    this.$message.error(res.data.data.errmsg)
                }
            }).catch(error => {
                console.log(error)
            })
        }
    }
}
</script>
<style src="../assets/style/login.css" scoped></style>
